//
//  InputTextView.swift
//  AirlineReservation
//
//  Created by Kevin on 2019/12/26.
//  Copyright © 2019 Kevin. All rights reserved.
//

import UIKit

class InputTextView: UITextField {
    
    var isHaveLine:Bool = true
    
    override func draw(_ rect: CGRect) {
        if isHaveLine {
            let path = UIBezierPath()
            // 横线
            path.move(to: CGPoint(x: 0, y: rect.size.height))
            path.addLine(to: CGPoint(x: rect.size.width, y: rect.size.height))
            // 宽度
            path.lineWidth = 1
            // 文本颜色
            textColor = COLOR_NICE
            // 浅灰色
            UIColor.lightGray.setStroke()
            // 渲染
            path.stroke()
        }
    }
    
    override func drawPlaceholder(in rect: CGRect) {
        // 弱提示文本
        let title = placeholder ?? ""
        attributedPlaceholder = NSAttributedString(string: title, attributes: [.foregroundColor : UIColor.lightGray])
        // 必须设置在前，否则不生效
        super.drawPlaceholder(in: CGRect(x: 5, y: 0, width: bounds.size.width, height: bounds.size.height * 0.5))
    }
}
